//
//  UIImage+MLXExtension.h
//  MLX
//
//  Created by SY on 2018/9/25.
//  Copyright © 2018年 SY. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIImage (MLXExtension)
/**返回不受系统渲染的图片*/
+ (UIImage *)originImageWithName: (NSString *)name;
/**返回圆形图片*/
- (instancetype)circleImage;
+ (instancetype)circleImage:(NSString *)name;
//设置圆角
- (UIImage*)setRadius:(CGFloat)radius;
- (UIImage *)createRoundedRectsize:(CGSize)size radius:(NSInteger)r;
- (UIImage *)scaletoSize:(float)imageSize;
//设置图片的透明度
+ (UIImage *)imageWithColor:(UIColor *)color;
+ (UIImage *) imageWithFrame:(CGRect)frame color:(UIColor *)color alpha:(CGFloat)alpha;
//设置图片的底色
+ (UIImage*) imageToTransparent:(UIImage*) image isChangeGroundFloorColor:(UIColor *)changeGroundFloorColor;
//给定比例重新生成Image
-(UIImage *)drawImageWidth:(CGFloat)width;
/** 取图片某一位置像素的颜色 */
- (UIColor *)colorAtPixel:(CGPoint)point;
/** 获得灰度图 */
- (UIImage *)convertToGrayImage;
//获取一张高清的图片
+ (UIImage *)createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat)size;
/** 纠正图片的方向 */
- (UIImage *)fixOrientation;
/** 按给定的方向旋转图片 */
- (UIImage*)rotate:(UIImageOrientation)orient;
/** 垂直翻转 */
- (UIImage *)flipVertical;
/** 水平翻转 */
- (UIImage *)flipHorizontal;
/** 将图片旋转degrees角度 */
- (UIImage *)imageRotatedByDegrees:(CGFloat)degrees;
/** 将图片旋转radians弧度 */
- (UIImage *)imageRotatedByRadians:(CGFloat)radians;
/** 截取当前image对象rect区域内的图像 */
- (UIImage *)subImageWithRect:(CGRect)rect;
/** 压缩图片至指定尺寸 */
- (UIImage *)rescaleImageToSize:(CGSize)size;
/** 压缩图片至指定像素 */
- (UIImage *)rescaleImageToPX:(CGFloat )toPX;
/** 在指定的size里面生成一个平铺的图片 */
- (UIImage *)getTiledImageWithSize:(CGSize)size;
/** 将两个图片生成一张图片 */
+ (UIImage*)mergeImage:(UIImage*)firstImage withImage:(UIImage*)secondImage;
/** 用一个Gif生成UIImage，传入一个GIFData */
+ (UIImage *)animatedImageWithAnimatedGIFData:(NSData *)theData;
/** 用一个Gif生成UIImage，传入一个GIF路径 */
+ (UIImage *)animatedImageWithAnimatedGIFURL:(NSURL *)theURL;
//调整图片尺寸和大小
+ (NSData *)reSizeImageData:(UIImage *)sourceImage maxImageSize:(CGFloat)maxImageSize maxSizeWithKB:(CGFloat) maxSize;
//UIImage图片缩放 等比缩放
+ (UIImage *) scaleImage:(UIImage *)image toScale:(float)scaleSize;
//对图片的模糊处理
- (UIImage *)applyLightEffect;
- (UIImage *)applyExtraLightEffect;
- (UIImage *)applyDarkEffect;
// 生成一张普通的二维码
+ (UIImage *)generateWithDefaultQRCodeData:(NSString *)data imageViewWidth:(CGFloat)imageViewWidth;
// 生成一张带有logo的二维码（logoScaleToSuperView：相对于父视图的缩放比取值范围0-1；0，不显示，1，代表与父视图大小相同）
+ (UIImage *)generateWithLogoQRCodeData:(NSString *)data logoImageName:(NSString *)logoImageName logoScaleToSuperView:(CGFloat)logoScaleToSuperView;
//当前View大小截图
+(UIImage *)screenshot:(UIView *)view;
/** UIView转化为UIImage */
+ (UIImage *)imageFromView:(UIView *)view;

- (CVPixelBufferRef)pixelBuffer;
/**
 *  生成图片 用于会话UISearchBar的背景颜色
 *  @param color  图片颜色
 *  @param height 图片高度
 *  @return 生成的图片
 */
+ (UIImage*)GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height;
//生成一个带文字的图片
+ (UIImage *)imageRepresentationFont:(UIFont *)initialsFont CGRect:(CGRect)frame string:(NSString *)string backgroundColor:(UIColor *)backgroundColor initialsColor:(UIColor *)initialsColor;

+ (UIImage *)imageOfUrl:(NSString *) urlstring;
@end
